home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 52
/
Volume 52 - JOGO DISK .iso
/
Games
/
shopdrop.swf
/
scripts
/
__Packages
/
Player.as
< prev
next >
Wrap
Text File
|
2007-09-27
|
9KB
|
305 lines
class Player extends MovieClip
{
var nPackages = 0;
var stackMax = 7;
var nCrap = 3;
var cCrap = 0;
var packHorizMove = 20;
var stackM = 0;
var mdir = 0;
var kickMultiplier = 7;
var sFrame = "walk";
var stackLength = 7;
var nBalance = 10;
var cBalance = 0;
var bBalance = false;
function Player()
{
super();
var _loc4_ = 500;
this.swapDepths(_loc4_);
_global.nPlayerY = this._y;
Player.floor = this.mcFloor._y - this.packageHolder._y;
this.mcConstLeft = this._parent.mcConstraintLeft;
this.mcConstRight = this._parent.mcConstraintRight;
this.pOrigin = new smashing.Point(this._x,this._y);
}
function updateWalk(nElapsed)
{
var _loc9_ = this.aStack.length;
this._x = _global.mcRoot._xmouse;
if(this._x < this.mcConstLeft._x)
{
this._x = this.mcConstLeft._x;
}
if(this._x > this.mcConstRight._x)
{
this._x = this.mcConstRight._x;
}
var _loc4_ = undefined;
var _loc14_ = this.aPackages.length;
var _loc5_ = undefined;
_loc4_ = 0;
while(_loc4_ < _loc14_)
{
_loc5_ = this.aPackages[_loc4_];
if(_loc5_ != null)
{
if(_loc5_.lastY >= this._y && _loc5_._y <= this._y)
{
if(this.a.hitTest(_loc5_))
{
if(_loc5_.bGrabbed == false)
{
switch(_loc5_.nType)
{
case GrabPackage.NORMAL:
_loc5_.bGrabbed = true;
this.addPackage();
_loc5_.a.play();
_loc9_ = _loc9_ + 1;
break;
case GrabPackage.BONUS:
this.oWorld.onBonus();
_loc5_.a.play();
break;
case GrabPackage.BALANCE:
this.balance();
_loc5_.a.play();
}
}
}
}
}
_loc4_ = _loc4_ + 1;
}
if(_loc9_ > 1)
{
var _loc22_ = nElapsed * smashing.Phys.gr * (_loc9_ * 1.7) * this.oWorld.level;
this.vStack.y += _loc22_;
var _loc10_ = new smashing.Point(this.vStack.x - this._x,this.vStack.y - this._y);
var _loc18_ = StackPackage.packageHeight * this.stackLength;
this.stackM -= smashing.Phys.drag(this.stackM,nElapsed);
if(this.stackM < 1)
{
this.stackM = 0;
}
if(this.bBalance == false)
{
_loc10_.x += this.stackM * nElapsed * this.mdir;
_loc10_.length = _loc18_;
}
else
{
_loc10_.x = 0;
_loc10_.y = -1;
_loc10_.length = _loc18_;
this.cBalance += nElapsed;
_global.mcRoot.mcMenu.mcBalance.display.mcPercent.gotoAndStop(Math.ceil(this.cBalance));
if(this.cBalance >= this.nBalance)
{
this.unBalance();
}
}
this.vStack.x = this._x + _loc10_.x;
this.vStack.y = this._y + _loc10_.y;
var _loc17_ = undefined;
if(this.vStack.x > this.mcConstRight._x)
{
_loc17_ = Math.abs(this.mcConstRight._x - this._x) * this.kickMultiplier;
this.vStack.x = this.mcConstRight._x;
this.stackM += _loc17_;
this.mdir = -1;
}
else if(this.vStack.x < this.mcConstLeft._x)
{
_loc17_ = Math.abs(this.mcConstLeft._x - this._x) * this.kickMultiplier;
this.vStack.x = this.mcConstLeft._x;
this.stackM += _loc17_;
this.mdir = 1;
}
var _loc19_ = smashing.Phys.pUp.dot(_loc10_) / _loc18_;
if(_loc19_ >= 1)
{
_loc19_ = 1;
}
var _loc20_ = Math.acos(_loc19_);
var _loc13_ = smashing.Phys.pHoriz.dot(_loc10_);
if(_loc13_ == 0)
{
_loc13_ = 1;
}
_loc13_ /= Math.abs(_loc13_);
_loc20_ *= _loc13_;
var _loc12_ = _loc20_ / _loc9_;
var _loc15_ = _loc12_ / 3.141592653589793 * 180;
var _loc8_ = undefined;
var _loc7_ = undefined;
var _loc6_ = new smashing.Point(0,0);
_loc4_ = 0;
while(_loc4_ < _loc9_)
{
_loc5_ = this.aStack[_loc4_];
_loc7_ = _loc12_ * _loc4_;
_loc5_._x = _loc6_.x;
_loc5_._y = _loc6_.y;
_loc5_._rotation = _loc15_ * _loc4_;
_loc8_ = new smashing.Point(Math.sin(_loc7_),- Math.cos(_loc7_));
_loc8_.length = StackPackage.packageHeight;
_loc6_.addPointMe(_loc8_);
_loc4_ = _loc4_ + 1;
}
var _loc16_ = Math.abs(_loc20_ / 3.141592653589793);
if(_loc16_ >= 0.5)
{
this.collapse();
}
var _loc11_ = _global.mcRoot.mcXHair;
_loc11_._visible = true;
_loc11_._x = this.vStack.x;
_loc11_._y = this.vStack.y;
if(this.bBalance == false)
{
_loc11_._visible = true;
_loc11_.a.gotoAndStop(Math.ceil(_loc16_ / 0.5 * 3));
}
else
{
_loc11_._visible = false;
}
_loc11_._rotation = (- _loc16_) * 180 * _loc13_;
}
else
{
_global.mcRoot.mcXHair._visible = false;
}
this.nPackages = this.aStack.length;
_root.nDebug1 = this.stackM;
}
function updateCollapse(nElapsed)
{
_global.mcRoot.mcXHair._visible = false;
this.a.change();
this.cCrap += nElapsed;
var _loc4_ = Math.floor((1 - this.cCrap / this.nCrap) * 100);
var _loc3_ = 0;
while(_loc3_ < this.aStack.length)
{
this.aStack[_loc3_].update(nElapsed);
this.aStack[_loc3_]._alpha = _loc4_;
_loc3_ = _loc3_ + 1;
}
if(this.cCrap >= this.nCrap)
{
this.oWorld.onUncollapse();
}
}
function reset()
{
this.stackM = 0;
this.sFrame = "walk";
this.update = this.updateWalk;
this.removeAllPackages();
this.addPackage(true);
this.cCrap = 0;
this.nPackages = this.aStack.length;
this._x = this.pOrigin.x;
this._y = this.pOrigin.y;
_global.mcRoot.mcXHair._visible = false;
}
function startWalk()
{
this.a.clothes.pants.play();
}
function stopWalk()
{
this.a.clothes.pants.stop();
}
function addPackage(bReset)
{
if(bReset != true)
{
_global.oSound.playSnd("pickUp");
}
var _loc3_ = this.aStack.length;
if(_loc3_ < this.stackMax)
{
var _loc4_ = this.packageHolder.attachMovie("mcObjects","clip" + _loc3_,_loc3_);
this.aStack.push(_loc4_);
if(this.aStack.length == 2)
{
this.vStack = new smashing.Point(this._x,(- StackPackage.packageHeight) * this.stackLength + this._y);
this.stackM = 15;
this.mdir = 1;
}
else if(this.aStack.length == 1)
{
_loc4_.nObject = 3;
}
}
else
{
this.oWorld.onMaxStack();
}
if(_loc3_ == this.stackMax - 1)
{
this.oPackages.toGiftCards();
var _loc5_ = _global.mcRoot.mcPopups;
_loc5_._visible = true;
_loc5_.gotoAndPlay("maxStack");
_global.mcRoot.mcMusic.fadeToTwo();
}
}
function removeAllPackages()
{
var _loc2_ = 0;
while(_loc2_ < this.aStack.length)
{
this.aStack[_loc2_].removeMovieClip();
_loc2_ = _loc2_ + 1;
}
this.aStack = [];
}
function collapse()
{
var _loc6_ = this.aStack.length;
var _loc5_ = new smashing.Point(this.vStack.x - this._x,this.vStack.y - this._y);
var _loc4_ = smashing.Phys.pHoriz.dot(_loc5_);
if(_loc4_ == 0)
{
_loc4_ = 1;
}
_loc4_ /= Math.abs(_loc4_);
var _loc3_ = 0;
while(_loc3_ < this.aStack.length)
{
this.aStack[_loc3_].m = new smashing.Point(this.packHorizMove * _loc3_ * _loc4_,0);
_loc3_ = _loc3_ + 1;
}
this.update = this.updateCollapse;
this.oWorld.onCollapse();
this.sFrame = "ohcrap";
this.a.change();
this.oPackages.toPackages();
_global.mcRoot.mcXHair._visible = false;
}
function balance()
{
_global.mcRoot.mcMenu.mcBalance.gotoAndPlay(2);
_global.oSound.playSnd("pickUp");
this.cBalance = 0;
this.bBalance = true;
}
function unBalance()
{
_global.mcRoot.mcMenu.mcBalance.gotoAndStop(1);
this.bBalance = false;
this.stackM = 15;
this.mdir = 1;
}
function onEnterFrame()
{
this.gotoAndStop(this.sFrame);
}
}